Skip to content

feat: pass _meta parameter through to MCP SDK call_tool#412

Open
Peter Houghton (peter-houghton) wants to merge 1 commit intolangchain-ai:mainfrom
peter-houghton:feat/pass-meta-to-call-tool
Open

feat: pass _meta parameter through to MCP SDK call_tool#412
Peter Houghton (peter-houghton) wants to merge 1 commit intolangchain-ai:mainfrom
peter-houghton:feat/pass-meta-to-call-tool

Conversation

@peter-houghton
Copy link

@peter-houghton Peter Houghton (peter-houghton) commented Jan 31, 2026

Summary

  • Enables the MCP protocol's _meta parameter to be passed through to MCP servers when invoking tools
  • Adds meta field to MCPToolCallRequest dataclass and _MCPToolCallRequestOverrides for interceptor support
  • Extracts _meta from tool arguments and passes it to session.call_tool()

Related Issue

Proposal for #410

How It Works

When invoking an MCP tool, you can include a _meta field in the tool arguments. This metadata is extracted from the arguments and passed through to the MCP server via session.call_tool().

For example, to pass a correlation ID or user ID for tracing/auditing purposes:

# When invoking a tool, include _meta in the arguments
tool_args = {
    "query": "search term",
    "_meta": {
        "correlationId": "abc-123-xyz",
        "userId": "user_456",
        "requestSource": "web-app"
    }
}

The MCP server receives the _meta object as part of the CallToolRequest, allowing it to:

  • Track requests across distributed systems using correlation IDs
  • Implement user-specific logic or audit logging
  • Route requests based on custom metadata in multi-tenant scenarios

Changes

  • Added meta field to MCPToolCallRequest dataclass
  • Added meta to _MCPToolCallRequestOverrides for interceptor support
  • Extract _meta from tool arguments and pass to session.call_tool()
  • Added tests for _meta passthrough functionality
  • Added documentation for _meta usage in README

MCP Specification Reference

Per the MCP spec (2025-06-18), _meta is reserved to allow clients and servers to attach additional metadata to their interactions, including:

  • Custom routing and context information
  • Server-specific metadata for multi-tenant or federated scenarios

This change enables the MCP protocol's _meta parameter to be passed through
to MCP servers when invoking tools. The _meta field is part of the MCP
specification and allows clients to attach additional metadata to their
requests.

Per the MCP spec (2025-06-18), _meta is reserved to allow clients and servers
to attach additional metadata to their interactions. This includes:
- Custom routing and context information
- Server-specific metadata for multi-tenant or federated scenarios

Changes:
- Add 'meta' field to MCPToolCallRequest dataclass
- Add 'meta' to _MCPToolCallRequestOverrides for interceptor support
- Extract _meta from tool arguments and pass to session.call_tool()
- Add tests for _meta passthrough functionality
- Add documentation for _meta usage in README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant